<?php
/**
 * @version     3.0
 * @package     com_sinhvien
 * @copyright   Copyright (C) 2013. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @author      quyen <quyennguyen.soict@gmail.com> - http://
 */
// no direct access
defined('_JEXEC') or die;
?>
<script>
    // Wait until the DOM has loaded before querying the document
    $(document).ready(function(){
        $('ul.tabs').each(function(){
            // For each set of tabs, we want to keep track of
            // which tab is active and it's associated content
            var $active, $content, $links = $(this).find('a');
 
            // If the location.hash matches one of the links, use that as the active tab.
            // If no match is found, use the first link as the initial active tab.
            $active = $($links.filter('[href="'+location.hash+'"]')[0] || $links[0]);
            $active.addClass('active');
            $content = $($active.attr('href'));
 
            // Hide the remaining content
            $links.not($active).each(function () {
                $($(this).attr('href')).hide();
            });
 
            // Bind the click event handler
            $(this).on('click', 'a', function(e){
                // Make the old tab inactive.
                $active.removeClass('active');
                $content.hide();
 
                // Update the variables with the new link and content
                $active = $(this);
                $content = $($(this).attr('href'));
 
                // Make the tab active.
                $active.addClass('active');
                $content.show();
 
                // Prevent the anchor's default click action
                e.preventDefault();
            });
        });
    });
</script>
<div id="lop">
    <hr>
    <ul class='tabs'>
    <li><a href='#tab1'>Danh sách lớp</a></li>
    <li><a href='#tab2'>Bảng điểm giữa kì</a></li>
    <li><a href='#tab3'>Bảng điểm cuối</a></li>
  </ul>
    <hr>
 <div id='tab1'>
    <div class="lop-left">
        <b>Tên môn học : <?php echo $this->item->ten_hp; ?></b>
    </div>
    <div class="lop-left">
        <b>Tên giảng viên:  <?php echo $this->item->ten_gv; ?></b>
    </div>
    <div class="clear"></div>
    <div class="lop-left">
        <b>Mã lớp học: <?php echo $this->item->ma_lop; ?></b>
    </div>
    <div class="lop-left">
        <b>Học kì:  <?php echo $this->item->ma_hocki; ?></b>
    </div>
    <div class="clear"></div>
    <hr>
    <p>Bảng điểm giữa kì: <?php if(empty($this->item->diem_gk)) { echo "chưa có.";
    } else {?>  đã có vui lòng bấm vào bảng điểm giữa kì.<?php } ?> </p>
    <p>Bảng điểm giữa kì: <?php if(empty($this->item->diem_ck)) { echo "chưa có.";
    } else {?>  đã có vui lòng bấm vào bảng điểm cuối kì. <?php } ?></p>
     <table id="sinhvienList" class="table table-striped">
            <thead>
                <tr>
                    <th class="left">
                        STT
                    </th>
                    <th class="left">
                        Mã sinh viên
                    </th>
                    <th class="left">
                        Tên sinh viên
                    </th>
                    
                </tr>
            </thead>
            <tbody>
            <?php
                                $db = JFactory::getDbo();
                                $query = $db->getQuery(true);
                                $query->select('*');
                                $query->from('#__dangkilop AS a');
                                $query->join('LEFT', '#__lop AS b ON b.ma_lop = a.ma_lop');
                                $query->where('a.ma_lop=' . $this->item->ma_lop);
                                $db->setQuery($query);
                                $rows = $db->loadObjectList();
                                $i=0;
                                foreach ($rows AS $key => $list) {
                                    $i++;
                                    ?>
                                    <tr>
                                        <th>
                                        <?php echo "$i"; ?>
                                        </th>
                                        <th>
                                             <?php echo "$list->ma_sv"; ?>
                                        </th>
                                        <th>
                                             <?php echo "$list->ten_sv"; ?>
                                        </th>
                                    </tr>
                                <?php
                                }
                                ?>   
            </tbody>

        </table>
 </div>
    <div id='tab2'>
        <?php echo $this->item->diem_gk; ?>
    </div>
    <div id='tab3'>
        <?php echo $this->item->diem_ck; ?>
    </div>
</div>




